﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WinAlarmManage.UControls
{
    public partial class UPump : UserControl
    {
        public UPump()
        {
            InitializeComponent();
        }


        private Bitmap lightImg = WinAlarmManage.Properties.Resources.light_off;

        /// <summary>
        /// 水泵状态指示灯图片
        /// </summary>
        public Bitmap LightImg
        {
            get { return lightImg; }
            set
            {
                lightImg = value;
                pictureBox1.Image = lightImg;
            }
        }



        private Color btnBgColor = Color.Green;

        /// <summary>
        /// 按钮背景色
        /// </summary>
        public Color BtnBgColor
        {
            get { return btnBgColor; }
            set
            {
                btnBgColor = value;
                button1.BackColor = btnBgColor;
            }
        }

        private string btnText="OFF";

        public string BtnText {
            get { return btnText; }
            set
            {
                btnText = value;
                button1.Text = btnText;
            }
        }



        private string pumpStateName ;


        public string PumpStateName
        {
            get { return pumpStateName; }
            set
            {
                pumpStateName = value;
            }
        }



        private bool actualState;

        public bool ActualState
        {
            get { return actualState; }
            set
            {
                actualState = value;
                if (actualState)
                {
                    lightImg = WinAlarmManage.Properties.Resources.light_on;
                    BtnBgColor = Color.Orange;
                    BtnText = "ON";
                }
                else {
                    lightImg = WinAlarmManage.Properties.Resources.light_off;
                    BtnBgColor = Color.Green;
                    BtnText = "OFF";
                }
            }
        }

        /// <summary>
        /// 状态改变事件
        /// </summary>
        public event EventHandler ChangedStateClick;

        private void button1_Click(object sender, EventArgs e)
        {
            ChangedStateClick?.Invoke(this, EventArgs.Empty);
        }
    }
}
